var markerArray = new Array();
var labelArray = new Array();
var markerClusterer;
var mapIconShow = {};
function BaiduMapHandler(_map, mapPath) {
	this.map = _map;
	this.gpsDataMap = {}; //保存当前的实时数据,以GpsRealData表的Id为主键

	this.markerMap = {}; //保存当前的实时marker,以GpsRealData表的Id为主键
	this.areaMap = {}; //保存当前的区域overlay和文本标注,已Enclosure围栏表的id为主键.

	this.mapPath = mapPath;

	this.realDataMap = {};

	//轨迹中回放中的marker, 线等，便于批量清楚
	this.routeOverlays = new Array();
}

/**
 * 根据车速、方向、报警和上线状态来生成车辆地标
 */
BaiduMapHandler.prototype.getRecordImageUrl = function (gpsData) {
	if (!gpsData.course) {
		gpsData.course = 0;
	}
	var img = setAngleImage1(gpsData.course);
	if (gpsData.status == 1) {
		if(gpsData.speed>0){
			if(gpsData.warnning==1){
				return "/img/alarm/"+img;
			}else{
				return "/img/direction/"+img;
			}
		}else{
			if(gpsData.warnning==1){
				return "/img/direction/parking/parkalarm.png";
			}else{
				return "/img/direction/parking/parking.png";
			}
		}
	}else{
		return "/img/direction/off/offline.png";
	}
}

BaiduMapHandler.prototype.setCenter = function (lat, lng, zoom) {
	if (!zoom)
		zoom = this.map.getZoom();
	this.map.centerAndZoom(new BMap.Point(lng, lat), 13);
}

BaiduMapHandler.prototype.setCityCenter = function (city,zoom) {
	this.map.centerAndZoom(city,zoom);
	this.map.enableScrollWheelZoom();
}

var gpsDataArray = [];
/**
 * 批量在地图上显示gps车辆地标
 * @gpsDataArray页面传送的gps数据，可以同时显示多个地标，所以是数组
 * @isOpenInfoWindow 是否打开信息窗口
 */
BaiduMapHandler.prototype.showMarkers = function (gpsDataArray) {
	for (var i = 0; i < gpsDataArray.length; i++) {
		var gpsData = gpsDataArray[i];
		if (gpsData.longitude > 1 && gpsData.latitude > 1) {
			var iconPath = this.getRecordImageUrl(gpsData);
			var icon = this.createIcon(iconPath, 32);
			this.addRealDataMarker(gpsData.longitude, gpsData.latitude, icon, gpsData, false);
		}
	}
}

/**
 * 在地图上显示gps车辆地标
 * @gpsDataArray页面传送的gps数据，可以同时显示多个地标，所以是数组
 * @isOpenInfoWindow 是否打开信息窗口
 */
BaiduMapHandler.prototype.showMarker = function (gpsData) {
	var lat = parseFloat(gpsData.latitude).toFixed(6);
	var lng = parseFloat(gpsData.longitude).toFixed(6);
	if (lat > 1 && lng > 1) {
		this.setCenter(lat,lng,13);
		var iconPath = this.getRecordImageUrl(gpsData);
		var icon = this.createIcon(iconPath, 32);
		this.addDataMarker(lng, lat, icon, gpsData);
	}
}

/**
 * 点击分组清除地图车辆图标
 */
BaiduMapHandler.prototype.clearMarkers = function () {
	for (var i = 0; i < gpsDataArray.length; i++) {
		var gpsDataMark = gpsDataArray[i];
		var gpsDataLabel = labelDataArray[i];
		this.map.removeOverlay(gpsDataMark);
		this.map.removeOverlay(gpsDataLabel);
	}
}


/**
 * 点击设备清除地图车辆图标
 */
BaiduMapHandler.prototype.clearMarkerDevice = function (sim) {
	var rd = mapIconShow[sim];
	markerClusterer.removeMarker(rd.marker);
	delete this.realDataMap[sim];
}



/**
 * 批量在地图上显示gps车辆地标
 * @gpsDataArray页面传送的gps数据，可以同时显示多个地标，所以是数组
 * @isOpenInfoWindow 是否打开信息窗口
 */
BaiduMapHandler.prototype.centerMarkerOverlays = function (gpsDataArray, isOpenInfoWindow, isCenter) {
	for (var i = 0; i < gpsDataArray.length; i++) {
		var gpsData = gpsDataArray[i];
		if (gpsData.longitude < 1 || gpsData.latitude < 1 || gpsData.latitude == null)
			continue;
		var oldRealDataMarker = this.realDataMap[gpsData.simNo];
		//var descr = gpsData.dvsSim + "[" + gpsData.depName + "]";
		/**if (gpsData.dvsOnline) {
		if (gpsData.dvsSpeed == 0)
		descr += "停车中";
		else
		descr += "车速:" + gpsData.dvsSpeed + "km/h";
		} else
		 descr += "离线中";**/
		if (oldRealDataMarker != null) {
			var currentPos = new BMap.Point(gpsData.longitude, gpsData.latitude);
			oldRealDataMarker.marker.setPosition(currentPos);
			var iconPath = this.getRecordImageUrl(gpsData.direction, gpsData.velocity, gpsData.online, gpsData.alarmState);
			//oldRealDataMarker.marker.getIcon().setImageUrl(iconPath);
			var icon = this.createIcon(iconPath, 32);
			oldRealDataMarker.marker.setIcon(icon);
			//oldRealDataMarker.label.setPosition(currentPos);
			/*	if (gpsData.velocity > 1) {
			 oldRealDataMarker.marker.setRotation(gpsData.direction);
			 } else {
			 oldRealDataMarker.marker.setRotation(0);
			 }*/
			//oldRealDataMarker.label.setContent(descr);
			oldRealDataMarker.gpsData = gpsData;
			var htmlContent = window.parent.renderTemplate(gpsData);
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			oldRealDataMarker.marker.openInfoWindow(markerInfoWindow);
		} else if (!isNaN(gpsData.latitude)) {

			var iconPath = this.getRecordImageUrl(gpsData.direction, gpsData.velocity, gpsData.online, gpsData.alarmState);
			var icon = this.createIcon(iconPath, 32);
			// isOpenInfoWindow = false;
			//alert(gpsData.dvsLongitude);
			var marker = this.addRealDataMarker(gpsData.longitude, gpsData.latitude, icon, gpsData, isOpenInfoWindow);
			/*	if (gpsData.velocity > 1) {
			 marker.setRotation(gpsData.direction);
			 } else {
			 marker.setRotation(0);
			 }*/
			//var label = this.createMarkerLabel(gpsData.dvcSim, gpsData.dvsLatitude, gpsData.dvsLongitude, descr, 32);
			this.realDataMap[gpsData.simNo] = {marker: marker, gpsData: gpsData};
		}
		if (!isNaN(gpsData.latitude))
			if (isCenter)
				this.setCenter(gpsData.latitude, gpsData.longitude);
		//this.addGoogleMarker(marker);
	}
}


/**
 * 点击报警数据，展示在地图
 */
BaiduMapHandler.prototype.centerAlarmMarkerOverlays = function (alarm, isOpenInfoWindow, isCenter) {
	var oldRealDataMarker = this.realDataMap[alarm.simNo];
	if (oldRealDataMarker != null) {
		var currentPos = new BMap.Point(alarm.longitude, alarm.latitude);
		oldRealDataMarker.marker.setPosition(currentPos);
		var iconPath = this.getAlarmIconUrlByAlarmType(alarm.AlarmTypeForIcon);
		var icon = this.createIcon(iconPath, 32);
		oldRealDataMarker.marker.setIcon(icon);
		oldRealDataMarker.gpsData = alarm;
		var htmlContent = window.parent.renderTemplateAlarm(alarm);
		var markerInfoWindow = new BMap.InfoWindow(htmlContent);
		oldRealDataMarker.marker.openInfoWindow(markerInfoWindow);
	} else {

		var iconPath = this.getAlarmIconUrlByAlarmType(alarm.AlarmTypeForIcon);
		var icon = this.createIcon(iconPath, 32);
		var marker = this.addRealDataAlarmMarker(alarm.longitude, alarm.latitude, icon, alarm, isOpenInfoWindow);
		this.realDataMap[alarm.simNo] = {marker: marker, gpsData: alarm};

	}
	if (isCenter)
		this.setCenter(alarm.latitude, alarm.longitude);

}


BaiduMapHandler.prototype.planDriveRoute = function (startPOI, endPOI) {
	var driving = new BMap.DrivingRoute(this.map, {
		renderOptions: {
			map: this.map,
			panel: "r-result",
			autoViewport: true
		}
	});
	driving.search(startPOI, endPOI);

}

BaiduMapHandler.prototype.createLocalSearch = function (onSearchResult) {
	var me = this;
	var options = {
		onSearchComplete: function (results) {
			// 判断状态是否正确
			if (search.getStatus() == BMAP_STATUS_SUCCESS) {
				var poiList = [];
				for (var i = 0; i < results.getCurrentNumPois(); i++) {
					var poi = results.getPoi(i);
					var name = poi.title + ", " + results.getPoi(i).address;
					var code = i;
					poiList.push({result: name, value: poi.address, data: poi});
				}
				onSearchResult(me.keyword, poiList);
			}
		}
	};
	var search = new BMap.LocalSearch('泰州市', options);
	return search;
}

BaiduMapHandler.prototype.createVehicleMarker = function (bmPoint, bIcon, opt, isOpenInfoWindow) {
	var marker = new BMap.Marker(bmPoint, {icon: bIcon});  // 创建标注
	map.addOverlay(marker);              // 将标注添加到地图中
	var htmlContent = window.parent.renderTemplate(opt);
	var markerInfoWindow = new BMap.InfoWindow(htmlContent);
	marker.addEventListener("click", function () {
		this.openInfoWindow(markerInfoWindow);
	});
	if (isOpenInfoWindow) {
		marker.openInfoWindow(markerInfoWindow);
	}
	return marker;
}


BaiduMapHandler.prototype.createIcon = function (iconPath, width, height) {
	//默认是16*16
	if (!width)
		width = 16;
	if (!height)
		height = width;
	return new BMap.Icon(iconPath, new BMap.Size(width, height));
}

BaiduMapHandler.prototype.openInfoWindow = function (dvcSim) {
	var realData = this.realDataMap[dvcSim];
	if (realData) {
		var opt = realData.gpsData;
		var htmlContent = window.parent.renderTemplate(opt);
		var markerInfoWindow = new BMap.InfoWindow(htmlContent);
		realData.marker.openInfoWindow(markerInfoWindow);
	}
}

BaiduMapHandler.prototype.openInfoWindowAlarm = function (dvcSim) {
	var realData = this.realDataMap[dvcSim];
	if (realData) {
		var opt = realData.gpsData;
		var htmlContent = window.parent.renderTemplateAlarm(opt);
		var markerInfoWindow = new BMap.InfoWindow(htmlContent);
		realData.marker.openInfoWindow(markerInfoWindow);
	}
}

BaiduMapHandler.prototype.openHtmlWindow = function (marker, htmlContent) {
	var markerInfoWindow = new BMap.InfoWindow(htmlContent);
	marker.openInfoWindow(markerInfoWindow);
}


BaiduMapHandler.prototype.addMarker = function (lng, lat, icon, opt, isOpenInfoWindow) {
	var pt = new BMap.Point(lng, lat);
	//var myIcon = new BMap.Icon(iconPath, new BMap.Size(16,16));
	var marker = new BMap.Marker(pt, {icon: icon});  // 创建标注
	this.map.addOverlay(marker);              // 将标注添加到地图中
	if (opt) {
		var dvcId = opt.id;
		var me = this;
		var htmlContent = window.parent.renderTemplate(opt);
		marker.addEventListener("click", function () {
			//me.openInfoWindow(dvcId);
			//me.openHtmlWindow(marker,htmlContent);
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			marker.openInfoWindow(markerInfoWindow);
		});
		if (isOpenInfoWindow) {
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			marker.openInfoWindow(markerInfoWindow);
		}
	}
	return marker;
}

BaiduMapHandler.prototype.addHisGpsMarker = function (lng, lat, icon, opt, isOpenInfoWindow) {
	var pt = new BMap.Point(lng, lat);
	//var myIcon = new BMap.Icon(iconPath, new BMap.Size(16,16));
	var marker = new BMap.Marker(pt, {icon: icon});  // 创建标注
	this.map.addOverlay(marker);              // 将标注添加到地图中
	if (opt) {
		var dvcId = opt.id;
		var me = this;
		var htmlContent = window.parent.renderTemplateHisGps(opt);
		marker.addEventListener("click", function () {
			//me.openInfoWindow(dvcId);
			//me.openHtmlWindow(marker,htmlContent);
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			marker.openInfoWindow(markerInfoWindow);
		});
		if (isOpenInfoWindow) {
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			marker.openInfoWindow(markerInfoWindow);
		}
	}
	return marker;
}


BaiduMapHandler.prototype.updateMarker = function (marker, opt) {
	if (opt) {
		var dvcId = opt.id;
		var me = this;
		var htmlContent = window.parent.renderTemplateHisGps(opt);
		marker.addEventListener("click", function () {
			//me.openInfoWindow(dvcId);
			//me.openHtmlWindow(marker,htmlContent);
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			marker.openInfoWindow(markerInfoWindow);
		});
	}
	return marker;
}


BaiduMapHandler.prototype.addRealDataAlarmMarker = function (lng, lat, icon, opt, isOpenInfoWindow) {
	var pt = new BMap.Point(lng, lat);
	//var myIcon = new BMap.Icon(iconPath, new BMap.Size(16,16));
	var marker = new BMap.Marker(pt, {icon: icon});  // 创建标注
	this.map.addOverlay(marker);              // 将标注添加到地图中
	if (opt) {
		var dvcSim = opt.simNo;
		var me = this;
		marker.addEventListener("click", function () {
			me.openInfoWindowAlarm(dvcSim);
		});
		if (isOpenInfoWindow) {
			var htmlContent = window.parent.renderTemplateAlarm(opt);
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			marker.openInfoWindow(markerInfoWindow);
		}
	}
	return marker;
}

BaiduMapHandler.prototype.addRealDataMarker = function (lng, lat, icon, opt, isOpenInfoWindow) {
	var pt = new BMap.Point(lng, lat);
	var label = new BMap.Label(opt.plateno+"<br>["+opt.simno+"]", {position:pt,offset:new BMap.Size(16,32)});
	label.setStyle({
		transform: 'translateX(18%) translateY(-90%)',
		'text-align':'center',
		color:'#f2f2f2',
		'background-color':'#2487b7',
		border: '1px solid rgb(13, 80, 181)',
		padding:'3px'
	});
	var marker = new BMap.Marker(pt, {icon: icon});  // 创建标注
	marker.setLabel(label);
	this.map.addOverlay(marker);              // 将标注添加到地图中
	//添加点击弹出窗口
	addClickHandler(opt,marker);
	gpsDataArray.push(marker);
	labelDataArray.push(label);
}

BaiduMapHandler.prototype.addDataMarker = function (lng, lat, icon, opt) {
	var pt = new BMap.Point(lng, lat);
	var label = new BMap.Label(opt.plateno+"<br>["+opt.simno+"]", {position:pt,offset:new BMap.Size(16,32)});
	label.setStyle({
		transform: 'translateX(18%) translateY(-90%)',
		'text-align':'center',
		color:'#f2f2f2',
		'background-color':'#2487b7',
		border: '1px solid rgb(13, 80, 181)',
		padding:'3px'
	});
	var marker = new BMap.Marker(pt, {icon: icon});  // 创建标注
	marker.setLabel(label);
	this.map.addOverlay(marker);              // 将标注添加到地图中
	gpsDataArray.push(marker);
	labelDataArray.push(label);
}

function addClickHandler(opt,marker){
	marker.addEventListener("click",function(e){
		var title = opt.plateno+"["+opt.simno+"]";
		var content = "";
		content += "<div style='padding: 0px'>";
		content += "<table width='100%' border=1>";
		content += "<tr>";
		content += "<td align='right'>所属单位：</td>";
		content += "<td colspan='3'>"+opt.fleetname+"</td>";
		content += "</tr>";
		content += "<tr>";
		content += "<td align='right'>定位时间：</td>";
		content += "<td colspan='3'>"+opt.updatetime+"</td>";
		content += "</tr>";
		content += "<tr>";
		content += "<td align='right' width='20%'>车牌号：</td>";
		content += "<td width='30%'>"+opt.plateno+"</td>";
		content += "<td align='right' width='20%'>车辆类型：</td>";
		content += "<td width='30%'>"+opt.cartype+"</td>";
		content += "</tr>";
		content += "<tr>";
		content += "<td align='right'>终端编号：</td>";
		content += "<td>"+opt.carno+"</td>";
		content += "<td align='right'>SIM卡号：</td>";
		content += "<td>"+opt.simno+"</td>";
		content += "</tr>";
		content += "<tr>";
		content += "<td align='right'>速度：</td>";
		content += "<td>"+opt.speed+"</td>";
		content += "<td align='right'>方向：</td>";
		content += "<td>"+getAngleName(opt.course)+"</td>";
		content += "</tr>";
		content += "<tr>";
		content += "<td align='right'>经度：</td>";
		content += "<td>"+opt.longitude+"</td>";
		content += "<td align='right'>纬度：</td>";
		content += "<td>"+opt.latitude+"</td>";
		content += "</tr>";
		content += "<tr>";
		content += "<td align='right'>车辆限速：</td>";
		content += "<td>"+opt.limitspeed+"</td>";
		content += "<td align='right'>总公里数：</td>";
		content += "<td>"+opt.runtotal+"</td>";
		content += "</tr>";
		content += "<tr>";
		content += "<td align='right'>车辆位置：</td>";
		content += "<td colspan='3'>"+opt.address+"</td>";
		content += "</tr>";
		content += "</table>";
		content += "</div>";
		layer.open({
			type:1,
			title:title,
			area: ['380px', '250px'], //宽高
			content:content,
			offset: 'rb'
		});
	});
}

function openInfo(content,e,opts){
	var p = e.target;
	var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
	var infoWindow = new BMap.InfoWindow(content,opts);  // 创建信息窗口对象
	map.openInfoWindow(infoWindow,point); //开启信息窗口
}

BaiduMapHandler.prototype.addRealDataMarker_1 = function (lng, lat, icon, opt, isOpenInfoWindow) {
	var pt = new BMap.Point(lng, lat);
	//var myIcon = new BMap.Icon(iconPath, new BMap.Size(16,16));
	var marker = new BMap.Marker(pt, {icon: icon});  // 创建标注
	//this.map.addOverlay(marker);              // 将标注添加到地图中
	if (opt) {
		var dvcSim = opt.simNo;
		var me = this;
		marker.addEventListener("click", function () {
			me.openInfoWindow(dvcSim);
		});
		if (isOpenInfoWindow) {
			var htmlContent = window.parent.renderTemplate(opt);
			var markerInfoWindow = new BMap.InfoWindow(htmlContent);
			marker.openInfoWindow(markerInfoWindow);
		}
	}
	return marker;
}


BaiduMapHandler.prototype.createMarker = function (lng, lat, iconPath, opt, isOpenInfoWindow) {
	var pt = new BMap.Point(lng, lat);
	var myIcon = this.createIcon(iconPath);
	var marker = new BMap.Marker(pt, {icon: myIcon});  // 创建标注
	//map.addOverlay(marker);              // 将标注添加到地图中
	var htmlContent = window.parent.renderTemplate(opt);
	var markerInfoWindow = new BMap.InfoWindow(htmlContent);
	marker.addEventListener("click", function () {
		this.openInfoWindow(markerInfoWindow);
	});
	if (isOpenInfoWindow) {
		marker.openInfoWindow(markerInfoWindow);
	}
	return marker;
}
BaiduMapHandler.prototype.createPolyline = function (points) {
	var polyline = new BMap.Polyline(points,
		{strokeColor: "blue", strokeWeight: 2, strokeOpacity: 0.5});
	this.map.addOverlay(polyline);
	return polyline;
}
/**
 * 判断点是否在地图边界中
 */
BaiduMapHandler.prototype.isInMapBound = function (bmPoint) {
	var bounds = this.map.getBounds();
	return bounds.containsPoint(bmPoint);
}
/**
 * 创建标注
 */
BaiduMapHandler.prototype.createLabel = function (id, lat, lng, text, offsetY) {
	if (!offsetY)
		offsetY = -10;
	var offsetX = -8 * text.length / 2;
	//alert(offsetX);
	var point = new BMap.Point(lng, lat);
	var opts = {
		position: point,    // 指定文本标注所在的地理位置
		offset: new BMap.Size(offsetX, 26)    //设置文本偏移量
	}
	var label = new BMap.Label(text, opts);  // 创建文本标注对象
	label.setStyle({
		color: "blue",
		fontSize: "12px",
		height: "20px",
		border: 0,
		background: "transparent",
		lineHeight: "20px",
		fontFamily: "微软雅黑"
	});
	map.addOverlay(label);
	return label;
}

BaiduMapHandler.prototype.createMarkerLabel = function (id, lat, lng, text, offsetY) {
	if (!offsetY)
		offsetY = -10;
	var offsetX = -8 * text.length / 2;
	//alert(offsetX);
	var point = new BMap.Point(lng, lat);
	var opts = {
		position: point,    // 指定文本标注所在的地理位置
		offset: new BMap.Size(offsetX, 32)    //设置文本偏移量
	}
	var label = new BMap.Label(text, opts);  // 创建文本标注对象
	label.setStyle({
		color: "blue",
		fontSize: "12px",
		height: "20px",
		border: 0,
		background: "#CCFFCC",
		lineHeight: "20px",
		fontFamily: "微软雅黑"
	});
	map.addOverlay(label);
	return label;
}

BaiduMapHandler.prototype.createMarkerLabel1 = function (id, lat, lng, text, offsetY) {
	if (!offsetY)
		offsetY = -10;
	var offsetX = -8 * text.length / 2;
	//alert(offsetX);
	var point = new BMap.Point(lng, lat);
	var opts = {
		position: point,    // 指定文本标注所在的地理位置
		offset: new BMap.Size(offsetX, 32)    //设置文本偏移量
	}
	var label = new BMap.Label(text, opts);  // 创建文本标注对象
	label.setStyle({
		color: "blue",
		fontSize: "12px",
		height: "20px",
		border: 0,
		background: "#CCFFCC",
		lineHeight: "20px",
		fontFamily: "微软雅黑"
	});
	//map.addOverlay(label);
	return label;
}

/**
 *单独监控的时候，不断的刷新最新的位置图标
 */
BaiduMapHandler.prototype.createMarkerOverlayTrackMode = function (targetInfo) {
	//try {
	var currentPos = new BMap.Point(targetInfo.rLng, targetInfo.rLat);
	//过滤无效的日期时间
	//if (parseInt(targetInfo.gpsTime.split(" ")[0].split("-")[0]) < this._defaultYearFilter)
	//return;
	var operatorObj = this;
	// 创建标记
	var vehicledvsDirectionImagUrl = this.mapPath + "/images/dvsDirection/"
		+ setAngleImage(targetInfo.angleInt);
	//var currentGpsTimeMill = parseDate(targetInfo.gpsTime).getTime();

	// 绑定标记
	// this._handler.bindClickEvent(targetInfo.marker, targetInfo, this.bindClickEventHTML);
	/**
	 this._handler.bindClickEvent(targetInfo.marker, targetInfo, function(opts){
	return that.bindClickEventHTML(opts);
	},function() {
	operatorObj._handler.getAddress(targetInfo.id, targetInfo.rLat, targetInfo.rLng);
	});
	 */
	var gpsDataId = targetInfo.plateNo;
	var marker = this.markerMap[gpsDataId];
	var gpsData = this.gpsDataMap[gpsDataId];
	if (!marker) {
		var vehicleIcon = new BMap.Icon(vehicledvsDirectionImagUrl, new BMap.Size(32, 32));
		marker = this.createVehicleMarker(currentPos,
			vehicleIcon, targetInfo, false);

		this.markerMap[gpsDataId] = marker;
		this.setCenter(targetInfo.rLat, targetInfo.rLng, 16);
		this.markerMap[gpsDataId] = marker;
	} else {
		marker.setPosition(currentPos); //更新车辆的当前位置
		var dvsDirectionImagUrl = this.mapPath + "/images/toolbar/point.png";
		var icon = this.createIcon(dvsDirectionImagUrl);
		var dvsDirectionMarker = this.addMarker(gpsData.rLng, gpsData.rLat,
			icon, gpsData, false);
		var prePos = new BMap.Point(gpsData.rLng, gpsData.rLat);
		var distance = this.map.getDistance(prePos, currentPos);
		var points = new Array();
		points[0] = prePos;
		points[1] = currentPos;
		this.createPolyline(points);
		/**
		 if(distance < 20)
		 {
		 operatorObj._handler
		 .removeOverlay(preTargetInfo.marker); //清楚掉前面的marker,避免密集显示图标
		 //return;
		 }else
		 {
		 preTargetInfo.marker.setIconImage(this._currentImageUrl);
		 }*/
	}
	if (this.isInMapBound(currentPos) == false) {
		this.setCenter(targetInfo.rLat, targetInfo.rLng);
	}
	this.gpsDataMap[gpsDataId] = targetInfo;
	//} catch (e) {

	//}
}
